#pragma once

#include "../dead6800/Dead6800.h"

class CDead63701:public CDead6800
{
public:
	u8 InternalRAM[0x100];		//internal ram

	u8 Port1Data,Port1DDR;
	u8 Port2Data,Port2DDR;

	u8 TCSR;
	u8 TCSRInfo;
	u8 Interrupts2;
	u8 RAMCtrlReg;
	u8 Latch;
	u32 CompareData;
	u32 Counter;
	u32 TimeNext,TimeOver;

	//new
//	u8 TCSR;					//timer control status register
//	u16 Counter;			//free running counter
	u16 OutputCompare;	//output compare register
	u16 InputCapture;		//input capture register
	u8 TCSR2;				//timer control status register 2
	u8 ModeCtrl;			//rate/mode control register
	u8 TRCSR;				//Tx/Rx control status register
	u8 ReceiveData;		//receive data register
	u8 TransmitData;		//transmit data register
	u8 RAMCtrl;				//ram/port 5 control register
	u8 Port6Data,Port6DDR;
	u16 OutputCompare2;	//output compare register 2
	u8 TCSR3;				//timer control status register 3
	u8 TimeConstant;		//time constant register
	u8 Timer2Up;			//timer 2 up counter
	//u8 TestRegister;		//test register
protected:
	__inline u8 ReadInternalReg(u32 addr);
	__inline void WriteInternalReg(u32 addr,u8 data);
	void AddCycles(int n);			//add cycles to cycle counter
public:
	CDead63701();
	~CDead63701();
	void Reset();
	void Step();
	void SaveState(CState *s);
	void LoadState(CState *s);
	u8 OpRead(u32 addr);
	u8 Read(u32 addr);
	void Write(u32 addr,u8 data);
	u32 Disassemble(char *dest,u32 p);
	char *GenerateRegNames(char *dest);
	char *GenerateRegData(char *dest);
};
